//
//  HotTravelTableViewCell.m
//  Journey
//
//  Created by dllo on 16/5/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HotTravelTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation HotTravelTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}


-(void)createSubviews
{
    self.titleLabel = [[UILabel alloc] init];
 //   self.titleLabel.backgroundColor = [UIColor magentaColor];
  //  self.titleLabel.textColor = [UIColor greenColor];
    self.titleLabel.numberOfLines = 2;
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.numberOfLines = 2;
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.photo = [[UIImageView alloc] init];
 //   self.photo.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.photo];
    self.username = [[UILabel alloc] init];
    self.username.font = [UIFont systemFontOfSize:13];
    self.username.textColor = [UIColor grayColor];
   // self.username.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.username];
    self.views = [[UILabel alloc] init];
 //   self.views.backgroundColor = [UIColor redColor];
    self.views.textColor = [UIColor grayColor];
    self.views.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.views];
    self.replys = [[UILabel alloc] init];
 //   self.replys.backgroundColor = [UIColor redColor];
    self.replys.font = [UIFont systemFontOfSize:13];
    self.replys.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.replys];
   
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.photo.frame = CGRectMake(10 * WIDTHC , 10 * WIDTHC , ((self.contentView.frame.size.width - 40)/ 3 ) * WIDTHC, 80 * WIDTHC);
    self.titleLabel.frame = CGRectMake(20 + self.photo.frame.size.width, 10 + WIDTHC, self.photo.frame.size.width * 2 , self.photo.frame.size.height / 2);
    self.username.frame = CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 5, 100 * WIDTHC, 15 * WIDTHC);
    self.views.frame = CGRectMake(self.titleLabel.frame.origin.x, self.username.frame.origin.y + self.username.frame.size.height + 5, 50 * WIDTHC, 15 * WIDTHC);
    self.replys.frame = CGRectMake(self.views.frame.origin.x + self.views.frame.size.width+ 15, self.views.frame.origin.y, self.views.frame.size.width, 15 * WIDTHC);
    
    
    
}

-(void)setHotmodel:(HotTravelModel *)hotmodel
{
    _hotmodel = hotmodel;
    [self.photo sd_setImageWithURL:[NSURL URLWithString:_hotmodel.photo] placeholderImage:[UIImage imageNamed:@"image3"]];
    self.titleLabel.text = _hotmodel.title;
    self.username.text = _hotmodel.username;
    self.views.text = [_hotmodel.views stringValue];
    
    self.replys.text = _hotmodel.replys;
    
}



@end
